const { DataTypes, Sequelize } = require('sequelize');
const { sequelize } = require('../database');
const { v4: uuidv4 } = require('uuid');

const ComProductsSkus = sequelize.define('com_products_skus', {
    name: {
      type: DataTypes.STRING(225),
      field: 'name',
      allowNull: false,
      comment: "sku名称"
    },

    color: {
      type: DataTypes.STRING(64),
      field: 'color',
      comment: "颜色"
    },

    productId: {
      type: DataTypes.BIGINT,
      field: 'product_id',
      allowNull: false,
      comment: "商品id"
    },

    dimensions: {
      type: DataTypes.STRING(64),
      field: 'dimensions',
      comment: "尺寸"
    },

    currentPrice: {
      type: DataTypes.DECIMAL,
      field: 'current_price',
      defaultValue: "0.00",
      comment: "当前进货价"
    },

    retailPrice: {
      type: DataTypes.DECIMAL,
      field: 'retail_price',
      defaultValue: "0.00",
      comment: "建议零售价"
    },

    place: {
      type: DataTypes.STRING(64),
      field: 'place',
      comment: "发货地"
    },

    freight: {
      type: DataTypes.STRING(255),
      field: 'freight',
      comment: "运费"
    },

    profitMargin: {
      type: DataTypes.DECIMAL,
      field: 'profit_margin',
      defaultValue: "0.00",
      comment: "利润率"
    },

    createTime: {
      type: DataTypes.DATE,
      field: 'create_time',
      allowNull: false,
      comment: "创建日期"
    },

    id: {
      type: DataTypes.BIGINT,
      field: 'id',
      primaryKey: true,
      allowNull: false,
      autoIncrement: true,
      comment: "id"
    },

    remark: {
      type: DataTypes.STRING(255),
      field: 'remark',
      comment: "备注"
    }
}, {
  tableName: 'com_products_skus',
  timestamps: false,
  underscored: true,  // 启用字段映射
  freezeTableName: true  // 固定表名
});

module.exports = ComProductsSkus;